<?php
class User extends AppModel {
	var $name = 'User';
	var $id = 'id';
	var $primaryKey = 'id';
	 
	function validateLogin($data) {
		$data['password'] = Security::hash($data['password']);
		$user = $this->find(array('login' => $data['username'], 'password' => $data['password'], 'status' => 'ACTIVO'), array('login', 'first_name', 'last_name', 'role', 'status'));
		if(!empty($user)) {
			return $user['User'];
		} else {
			return false;
		}
	}
	
	function getUserRole($user) {
		$role = $this->field("role","login = '$user'");
		return $role;
	}
}
?>